﻿using InfluxDB.Client;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace System;

public static class TSDBExtension
{
    public static IServiceCollection AddInfluxDB(this IServiceCollection services, IConfigurationSection section)
    {
        string url = section.GetSection("Url").Value;
        string token = section.GetSection("Token").Value;
        services.AddTransient<InfluxDBClient>(provider =>
        {
            return new InfluxDBClient(url, token);
        });
        return services;
    }
}